#include <iostream>
#include <string>
using namespace std;

struct sng{
	int a,b;
	bool can_change(sng x){
		if(a == 0){
			if(x.a != 0  &&  x.b != 0)
				return true;
			else
				return false;
		}
		else{
			if(x.a == 0)
				return false;
			else
				return b<x.b;
		}
	}
	void turn(string x){
		string now;
		for(int i=0;i<x.length();i++){
			if(x[i] == 'n'){
				a = now[0]-'0';
				for(int j=1;j<now.length()-1;j++)
					a = a*10+(now[j]-'0');
				if(now.length() > 1  &&  now[now.length()-1] != '*')
					a = a*10+(now[now.length()-1]-'0');
				now = "";
			}
			else if(x[i] == '^'){
				now = "";
			}
			else{
				now += x[i];
			}
		}
		b = now[0]-'0';
		for(int i=1;i<now.length();i++)
			b = b*10+(now[i]-'0');
		return;
	}
};



int main(){
	string s;
	string now;
	sng ans;
	ans.a = 0;
	ans.b = 1;
	cin>>s;
	for(int i=0;i<=s.length();i++){
		if(s[i] == '+'  ||  i == s.length()){
			sng l;
			l.turn(now);
			if(ans.can_change(l))
				ans = l;
			now = "";
		}
		else{
			now += s[i];
		}
	}
	if(ans.a != 0){
		if(ans.b != 1)
			cout<<"O(n^"<<ans.b<<")";
		else
			cout<<"O(n)";
	}
	else{
		cout<<"O(1)";
	}
	return 0;
}
// 10000000*n^1+123*12*n^10+23
// 10000000*n^1+12*n^0+23
// 10000000*n^1+12*n^10+43n^9
// 2*n^0+3*n^0
